/**
 * @file rank/popularize/luogu1928/main.cpp
 * @brief
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 2022/7/10 17:11:39
 **/

#include <bits/stdc++.h>
using namespace std;
string decompress() {
  int n;
  string s, s1;
  char c;
  while (cin >> c) {
    if (c == '[') {
      cin >> n;
      s1 = decompress();
      while (n--) s += s1;
    } else if (c == ']')
      break;
    else
      s += c;
  }
  return s;
}
int main() { cout << decompress() << endl; }
